<!DOCTYPE HTML>
<html>
<head>
    <title>安置帮教社会关系页面</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/common/common.js" type="text/javascript"></script>
</head>
<style>
    .delBtn {
        border:1px solid #ff2120;
        border-radius:10px;
        font-size:8px;
        line-height:20px;
        font-weight:bold;
        color:#ff4634;
    }
    .editBtn {
        border:1px solid #018d00;
        border-radius:10px;
        font-size:8px;
        line-height:20px;
        font-weight:bold;
        color:#00a60a;
    }
</style>
<body>
<div class="mini-fit">
    <#--罪犯编号-->
    <input id="priNum" name="priNum" class="mini-hidden" value="${priNum}" />
    <div style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;padding: 10px;">
        <div id="editform" class="form" style="padding:10px;">
            <span style="font-size: 15px">${pname!''}&emsp;</span>/<span style="font-size: 15px">${sex!''}</span>
        </div>
        <div id="editform2" class="form" style="padding:10px;">
            <table class="form-table" width="100%">
                <tr style="line-height: 30px;">
                    <td width="40%"><span style="color: #8B8B8B">身份证号:&emsp;</span>${idnum!''}
                    </td>
                    <td width="40%"><span style="color: #8B8B8B">出生日期:&emsp;</span>${age!''}
                    </td>
                </tr>
                <tr style="line-height: 30px;">
                    <td><span style="color: #8B8B8B">户籍地址:&emsp;</span>${hjdz!''}
                    </td>
                    <td><span style="color: #8B8B8B">居住地址:&emsp;</span>${jzdz!'无'}
                    </td>
                </tr>
            </table>
        </div>
        <div id="editform3" class="form" style="padding:10px;">
            <span style="font-size: 18px">帮教信息&emsp;&emsp;&emsp;</span> <a class="mini-button  mini-button-primary"
                                                                           onclick="addBfInfoData('${priNum!''}')">新增</a>
        </div>
        <div>
            <div id="datagrid1" class="mini-datagrid" style="width: 100%;" ajaxType="get" alwaysShowEmptyText="true"
                 autoload="true" showEmptyText="true" emptyText="暂无数据" multiSelect="true" showPager="false"
                 url="/azbj/azbjgl/bjgzgl/view/getBjInfoList?priNum=${priNum!''}">
                <div property="columns">
                    <div type="indexcolumn" align="center" width="10%" headerAlign="center" width="20%">序列</div>
                    <div name="dateBangfu" field="dateBangfu" width="20%" align="center" headerAlign="center" allowSort="false">教育时间
                    </div>
                    <div name="bjlx" field="bjlx" width="40%" align="center" headerAlign="center" allowSort="false">帮教类型
                    </div>
                    <div name="action" width="30%" align="center" headerAlign="center" renderer="onActionRenderer" allowSort="false">操作
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<script type="text/javascript">
    mini.parse();
    var ftab = 1;
    var priNumObj = mini.get("priNum");
    var grid = mini.get("datagrid1");

    //渲染列中按钮
    function onActionRenderer(e) {
        var s = '';
        s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="editBfInfoData()"  >&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>&nbsp';
        s += '&nbsp;<a class="mini-button mini-button-danger"   onclick="delBfInfoData()"   >&nbsp;&nbsp;删除&nbsp;&nbsp;</a>&nbsp';
        s += '&nbsp;<a class="mini-button mini-button-info"   onclick="viewBfInfoData()"   >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
        return s;
    }

    function editBfInfoData() {
        var row = grid.getSelected();
        mini.open({
            url: "/azbj/azbjgl/bjgzgl/view/toAddBjInfoTab?pp=" + row.pp + "&priNum=" + priNumObj.getValue(),
            title: "编辑-帮教信息",
            width: "70%",
            height: "60%",
            allowDrag: true,
            allowResize: false,
            showCloseButton: true,
            onload: function () {
            },
            ondestroy: function (action) {
                grid.reload();
            }
        });
    }

    function viewBfInfoData() {
        var row = grid.getSelected();
        mini.open({
            url: "/azbj/azbjgl/bjgzgl/view/toViewBjInfoTab?pp=" + row.pp + "&priNum=" + priNumObj.getValue(),
            title: "查看-帮教信息",
            width: "70%",
            height: "80%",
            allowDrag: true,
            allowResize: false,
            showCloseButton: true,
            onload: function () {
            },
            ondestroy: function (action) {
                grid.reload();
            }
        });
    }

    function delBfInfoData(e) {
        var cfStr = "确认删除该条帮教记录吗？"
        mini.confirm(cfStr, "确定？", function (action) {
            if (action == "ok") {
                var row = grid.getSelected();
                $.ajax({
                    url: "/azbj/azbjgl/azgzgl/view/delBjInfoAction?pp=" + row.pp + "&priNum=" + priNumObj.getValue(),
                    type: "post",
                    data: {delId: e},
                    success: function (result) {
                        if (result.code == 1) {
                            mini.alert("删除成功");
                            grid.reload();
                        }else if (result.code == 5599) {
                            mini.alert(result.message);
                        } else {
                            mini.alert("删除失败");
                        }
                    }
                });
            }
        });
    }

    //添加帮扶信息
    function addBfInfoData(PriNum) {
        mini.open({
            url: "/azbj/azbjgl/bjgzgl/view/toAddBjInfoTab?priNum=" + PriNum,
            title: "新增-帮教信息",
            width: "70%",
            height: "60%",
            allowDrag: true,
            allowResize: false,
            showCloseButton: true,
            onload: function () {
            },
            ondestroy: function (action) {
                if (action == 'close'){
                    //点击取消/×号
                    var iframe = this.getIFrameEl();
                    //获取选中、编辑的结果
                    var data = iframe.contentWindow.GetData();
                    var taskId = data.taskId;
                    var priNum = data.priNum;
                    var id = data.id;
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[0],
                        type: 'get',
                        success: function (success) {
                        }
                    });
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[1],
                        type: 'get',
                        success: function (success) {
                        }
                    });
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[2],
                        type: 'get',
                        success: function (success) {
                        }
                    });
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[3],
                        type: 'get',
                        success: function (success) {
                        }
                    });
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[4],
                        type: 'get',
                        success: function (success) {
                        }
                    });
                }
                grid.reload();
            }
        });
    }
</script>
</body>
</html>